package com.tanhua.server.controller;

import com.tanhua.dubbo.api.CommentApi;
import com.tanhua.server.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/comments")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @GetMapping
    public ResponseEntity<Object> comments(String movementId, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer pagesize) {
        return commentService.comments(movementId, page, pagesize);
    }

    @PostMapping
    public ResponseEntity<Object> commitComment(@RequestBody Map<String,String> params) {
        String movementId = params.get("movementId");
        String comment = params.get("comment");
        return commentService.commitComment(movementId, comment);
    }


}
